﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

namespace TestJQGrid
{
    public partial class AdhocAdjustment : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                fillAgents();
                fillTax();
            }
        }

        public void fillAgents()
        {
            DataTable dt = new DataTable();
            dt = GlobalMethods.ExecuteSelectQuery("select AgentId,AgentName from Agents where Status='Approved' order by AgentName");

            DDAgents.DataSource = dt;
            DDAgents.DataBind();
        }

        public void fillTax()
        {
            DataTable dt = new DataTable();
            dt = GlobalMethods.ExecuteSelectQuery("select * from ValidValues where TableName='Taxes' order by ColumnName");
            DDTaxes.DataSource = dt;
            DDTaxes.DataBind();
        }

        protected void JQGrid1_DataRequesting(object sender, Trirand.Web.UI.WebControls.JQGridDataRequestEventArgs e)
        {
            DataTable dt = getTaxDetailsPerAgents();
            if (dt == null) return;

            JQGrid1.DataSource = dt;
            JQGrid1.DataBind();
        }

        public DataTable getTaxDetailsPerAgents()
        {
            string query = "select * from AgentTaxMaster order by AgentID";

            DataTable dt = new DataTable();
            dt = GlobalMethods.ExecuteSelectQuery(query);

            return dt;
        }
    }
}